﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using ExtAspNet;
using GPCSC.Model;
using NickLee.Common;
using System.Data;

namespace GPCSC.Web.sjs
{
    public partial class GGHList : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                f_bound();
            }
        }
        protected void f_bound()
        {
            CL_USER_S user = reUser();
            string type = Usual.f_querystringToString("type");
            string iszuofei = Usual.f_querystringToString("iszuofei");
            types.Value = type;
            if (iszuofei == "1")
            {
                DataSet ds = new GGH_T().F_boundIsZuoFei(user.CL_USER_SOID.ToString(), type);
                if (ds.Tables.Count > 0)
                {
                    Grid1.DataSource = ds.Tables[0];
                    Grid1.DataBind();
                }

            }
            else
            {
                DataSet ds = new GGH_T().F_bound(user.CL_USER_SOID.ToString(), type);
                if (ds.Tables.Count > 0)
                {
                    Grid1.DataSource = ds.Tables[0];
                    Grid1.DataBind();
                }
            }
        }
    
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int count = 0;
            GPCSC.Webs.databyhtable dh = new GPCSC.Webs.databyhtable();
            Hashtable htable = new Hashtable();
            foreach (int row in Grid1.SelectedRowIndexArray)
            {
                htable.Clear();
                htable.Add("isdel", 1);
                dh.databyhtables(htable, "update", "GGH_table", "GGHID", Grid1.DataKeys[row][0].ToString());
                count++;
            }
            f_bound();
            if (count > 0)
            {
                Alert.Show("删除成功!");
            }
            else if (count == 0)
            {
                Alert.Show("没有删除成功!");
            }
        }
        public Hashtable f_getElements(Hashtable o_uiTable)
        {
            //UIFactory Get Values as Hashtable:界面工厂获取值，并保存在哈希表
            base.o_uiTable.Clear();
            base.o_uiTable = UIFactory.UIFactory_Get(this);
            return base.o_uiTable;
        }
        public CL_USER_S reUser()
        {

            byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
            CL_USER_S users = (GPCSC.Model.CL_USER_S)userInfoTable["SYS_USER"];
            return users;
        }
        protected string GetEditUrl(object id,object type)
        {
            string ids = id.ToString();
            string types = type.ToString();
            return "javascript:" + Window1.GetShowReference("GGHCount.aspx?id=" + id+"&types="+type);
        }
        protected void Window1_Close(object sender, EventArgs e)
        {
            f_bound();

        }
    }
}